package cn.tedu.spring.iocxml;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserTest {

    @Test
    public void idTest(){
        //加载配置文件
        ApplicationContext context=new ClassPathXmlApplicationContext("bean.xml");
        //获取对应类对象
        User user=(User) context.getBean("user");
        //调用类方法
        user.run();
    }
    @Test
    public void classTest(){
        //加载配置文件
        ApplicationContext context=new ClassPathXmlApplicationContext("bean.xml");
        //获取对应类对象
        User user=(User) context.getBean(User.class);
        //调用类方法
        user.run();
    }
    @Test
    public void idClassTest(){
        //加载配置文件
        ApplicationContext context=new ClassPathXmlApplicationContext("bean.xml");
        //获取对应类对象
        User user=(User) context.getBean("user2",User.class);
        //调用类方法
        user.run();
    }
}
